#include <QCoreApplication>
#include <QString>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    {
        QString str = "Hello";
        qDebug() << str;
    }

    {
        QString str;
        str.resize(4);

        str[0] = 'U';
        str[1] = 'n';
        str[2] = QChar(0x10e3);
        str[3] = QChar(0x03a3);
        QChar c = str.at(0);
        qDebug() << str << c;
    }

    {
        QString HuStr = "河to湖";
        // QChar::fromUsc2 从UTF-16字符c构造一个QChar, 该函数在Qt6.0引入
        QChar He = QChar::fromUcs2(HuStr[0].unicode());
        QChar Hu = QChar(HuStr[3].unicode());
        QString str = "他们来自河南或河北";
        for (int i = 0; i < str.size(); i++) {
            if (str.at(i) == He)
                str[i] = Hu;
        }
        qDebug() << str;
    }

    return a.exec();
}
